package com.zhang.modules.auth.rep;

import com.zhang.common.jpa.rep.BaseRep;
import com.zhang.modules.auth.eneity.Role;
import org.apache.logging.log4j.message.StringFormattedMessage;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

@Repository
public interface RoleRep extends BaseRep<Role, String> {
    @Transactional
    @Modifying
    @Query("delete from SysAclRolePermission s where s.permissionId not in ?1")
    int deleteByIdNotIn(Collection<String> ids);

    /**
     * 重置Role和权限关系表
     */
    @Transactional
    @Modifying
    @Query("delete from SysAclRolePermission s where s.roleId not in ?1")
    int resetRole(String roleId);



}